package homework;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Random;

public class Test11 {
//	作业2：
//	在你生成的文件中，随机点名名字，在控制台打印一行
	public static void main(String[] args) throws IOException {
		File path = new File("D:\\FileTest\\name.txt");
		BufferedReader br = new BufferedReader(new FileReader(path));
		String line="";
		ArrayList<String> textLine = new ArrayList<>();
		while((line=br.readLine())!=null){
			if(line.length()>0)textLine.add(line);
		}
		br.close();
		Random rd = new Random();
		int rdName = rd.nextInt(100)+1;
		String[] arr = textLine.get(rdName).split("-");
		System.out.println(textLine);
		System.out.println("随机到了第"+rdName+"号:"+arr[0]);
	}
}
